﻿using System;
using System.Web;
using BONSAI.BLL;
using BONSAI.Common;
using System.Linq;

namespace BONSAI.UI.Pages
{
    public partial class NewsDetail : System.Web.UI.Page
    {
        public string NewsId { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            NewsId = HttpContext.Current.Items[BONSAIConstants.NEWSID] + "";
            if(!IsPostBack)
            {
                BindNewsDetail(NewsId);
                
            }
        }
        private void BindNewsDetail(string id)
        {
            var lst = (new NewsBO()).GetByID(id);
            if (lst != null)
            {
                BindSameOtherNews(lst.Createdate);
                lbldate.Text = lst.Createdate.ToString("dd/MM/yyyy hh:mm:ss tt");
                lbltitle.Text = lst.NameFull;
                Literal1.Text = lst.Description;

               
            }
        }
        private void BindSameOtherNews(DateTime strDate)
        {
            var lst = (new NewsBO()).GetAll().Where(x => x.Createdate < strDate);
            //load same other news
            Repeater1.DataSource = lst;
            Repeater1.DataBind();
        }
    }
}